<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>PopupMenu.pb</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font><font color="#006666">;   PureBasic - Menu example file
</font><font color="#006666">;
</font><font color="#006666">;    (c) Fantaisie Software
</font><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font>
<font color="#006666">;
</font><font color="#006666">; Create the popup menu. The indent is important here for a good lisibility
</font><font color="#006666">;
</font>
<b><font color="#006666">If</font></b> <font color="#006666">CreatePopupMenu</font>(0)
<font color="#006666">  MenuItem</font>(1, "Cut")
<font color="#006666">  MenuItem</font>(2, "Copy")
<font color="#006666">  MenuItem</font>(3, "Paste")
<font color="#006666">  MenuBar</font>()
<font color="#006666">  OpenSubMenu</font>("Options")
<font color="#006666">    MenuItem</font>(4, "Window...")
<font color="#006666">    MenuItem</font>(5, "Gadget...")
<font color="#006666">  CloseSubMenu</font>()
<font color="#006666">  MenuBar</font>()
<font color="#006666">  MenuItem</font>( 6, "Quit")
<b><font color="#006666">EndIf</font></b>

<font color="#006666">;
</font><font color="#006666">; We just have to open a window and see when an event happen on the menu
</font><font color="#006666">;
</font><b><font color="#006666">If</font></b> <font color="#006666">OpenWindow</font>(0, 100, 100, 300, 260, "PureBasic - PopupMenu Example")

<font color="#006666">  ListIconGadget</font>(0, 10, 10, 280, 240, "Tools", 200)
<font color="#006666">    AddGadgetItem</font>(0, -1, "Hammer")
<font color="#006666">    AddGadgetItem</font>(0, -1, "Screwdriver")

  <b><font color="#006666">Repeat</font></b>

    <b><font color="#006666">Select</font></b> <font color="#006666">WaitWindowEvent</font>()
        
      <b><font color="#006666">Case</font></b> <font color="#924B72">#PB_Event_Gadget</font>
        <b><font color="#006666">If</font></b> <font color="#006666">EventGadget</font>() = 0 <b><font color="#006666">And</font></b> <font color="#006666">EventType</font>() = <font color="#924B72">#PB_EventType_RightClick</font>
<font color="#006666">          DisplayPopupMenu</font>(0,<font color="#006666"> WindowID</font>(0))
        <b><font color="#006666">EndIf</font></b>
          
      <b><font color="#006666">Case</font></b> <font color="#924B72">#PB_Event_Menu</font>
      
        <b><font color="#006666">Select</font></b> <font color="#006666">EventMenu</font>()  <font color="#006666">; To see which menu has been selected
</font>
          <b><font color="#006666">Case</font></b> 1 <font color="#006666">; Cut
</font><font color="#006666">            MessageRequester</font>("PureBasic", "Cut", 0)

          <b><font color="#006666">Case</font></b> 2 <font color="#006666">; Copy
</font><font color="#006666">            MessageRequester</font>("PureBasic", "Copy", 0)

          <b><font color="#006666">Case</font></b> 3 <font color="#006666">; Paste
</font><font color="#006666">            MessageRequester</font>("PureBasic", "Paste", 0)

          <b><font color="#006666">Case</font></b> 6 <font color="#006666">; Quit
</font>            Quit = 1

        <b><font color="#006666">EndSelect</font></b>
        
      <b><font color="#006666">Case</font></b> <font color="#924B72">#PB_Event_CloseWindow</font>
        Quit = 1

    <b><font color="#006666">EndSelect</font></b>

  <b><font color="#006666">Until</font></b> Quit = 1

<b><font color="#006666">EndIf</font></b>

<b><font color="#006666">End</font></b>  </font></pre>
</body></html>
